package fr.inserm.u915.organifooyi.model;

import fr.inserm.u915.organifooyi.web.Message;

public class Status
	{
	private boolean ok;
	private History history=null;
	private Message message=null;
	
	public Status(History history)
		{
		ok=true;
		this.history=history;
		}
	
	public Status(Message message)
		{
		this.message=message;
		}
	
	public boolean isOk()
		{
		return ok;
		}
	
	public History getHistory()
		{
		return history;
		}
	public Message getMessage()
		{
		return message;
		}
	public boolean isHistory()
		{
		return this.history!=null;
		}
	
	public boolean isIgnorable()
		{
		return history==null && (message==null || message.getLevel()==Message.Level.success);
		}
	@Override
	public String toString() {
		if(isIgnorable()) return "ignorable";
		if(isHistory()) return String.valueOf(history);
		return String.valueOf(message);
		}
	}	
